use aqua::server::prelude::*;

#[get(path = "/hello/<name>")]
fn hello(name: String) -> String {
    format!("Hello {}", name)
}

// /query/baidu?name=yc&age=23&score=1.2
#[get(path = "/query/<engine>", query = "name&age&score")]
fn with_query(engine: String, name: String, age: i32, score: f64) -> String {
    format!("Search: {name} {age} {score} from {engine}")
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    utils::init_logger();
    let server = Server::new();
    server
        .mount(router!(hello))
        .mount(router!(with_query))
        .run("127.0.0.1:7878").await?;

    Ok(())
}